package nl.twleaks.alice.tasks;

import static com.google.appengine.api.urlfetch.FetchOptions.Builder.doNotFollowRedirects;

import java.net.MalformedURLException;
import java.net.URL;

import com.google.appengine.api.urlfetch.HTTPHeader;
import com.google.appengine.api.urlfetch.HTTPMethod;
import com.google.appengine.api.urlfetch.HTTPRequest;

import nl.twleaks.alice.entities.User;
import nl.twleaks.alice.task.RequestTask;
import nl.twleaks.alice.task.Task;

@SuppressWarnings("serial")
public class LoginWorldTask extends RequestTask implements Task {
	

	public LoginWorldTask(User user) {
		super(user);
	}
	
	@Override
	public void beforeExecute() {
		try {
			request = new HTTPRequest(new URL(get("location")), HTTPMethod.GET, doNotFollowRedirects());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void afterExecute() {
		for(HTTPHeader header : response.getHeaders()) {
			System.out.println(header.getName() + ": " + header.getValue());
		}
	}

	public void afterTask() {

	}
}
